package com.fang.fen.sort;

public class Merge {


    public static void main(String[] args) {


        int[] array = new int[1000];

        mergeSort(array, 0, array.length - 1);

    }


    public static void mergeSort(int[] array, int low, int hight) {

        if (low < hight) {

            int mid = (hight - low) / 2;
            //deal Left
            mergeSort(array, low, mid);

            //deal Right
            mergeSort(array, mid + 1, hight);

            merge(array, low, mid, hight);

        }
    }
// 8 9 10 11   8 10 9 11
    public static void merge(int[] array, int low, int mid, int hight) {

        int ls = low;
        int rs = mid + 1;

        int temp = 0;
        for (int i = low; i <= hight; i++ ) {
            if(array[ls] > array[rs]) {
                temp = array[rs];
                array[ls] = array[ls];
                array[rs] = temp;
            }
        }

    }

}

